package com.zbf.并发包;

import java.util.concurrent.Semaphore;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/16  16:10
 * 描述:
 */
public class MySemphoneThread extends Thread {

    private Semaphore semaphore;

    public MySemphoneThread(Semaphore semaphore) {
        this.semaphore = semaphore;
    }

    @Override
    public void run() {

        try {
            semaphore.acquire();

            System.out.println(Thread.currentThread().getId()+"=========业务代码=======");
            Thread.sleep(1000);

            semaphore.release();

        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
